<script type="text/javascript">
	function ScoreCertCtrl(CtrlUtil, $http, $scope, modalService, $element) {
		var ctrl = this
		CtrlUtil.build(this, ':root/score/queryCertReApply', $scope.ctrl)
		this.audit = function(item) {
			var content = $element.find('[template]>[add]').clone()
			item.pass = true
			modalService.confirm({
				title : '结业证书补办申请',
				content : content,
				search : {
					enable : false,
					stuInfo : item.stuInfo
				},
				result : item,
				ctrl : ctrl
			}).then(function(r) {
				$http.post(':root/score/auditCertReApply', r).success(function(R) {
					if (R) {
						modalService.succ('审核成功', 1500)
						ctrl.query()
					} else {
						modalService.error('审核失败', 1500)
					}
				})
			})
		}
		this.toImageUrl = CtrlUtil.toImageUrl
		this.batch = function() {
			var checked = CtrlUtil.getChecked(ctrl)
			if (checked.length == 0) {
				return;
			}
			var ids = [];
			angular.forEach(checked, function(v) {
				ids.push(v.id);
			})
			var content = $element.find('[template]>[batch]').clone();
			modalService.confirm({
				title : '批量审核',
				desc : '你将批量审核' + ids.length + '条数据',
				content : content,
				result : {
					pass : true
				}
			}).then(function(r) {
				$http.post(':root/score/batchAuditCertReApply', {
					ids : ids,
					pass : r.pass
				}).success(function(r) {
					modalService.succ('批量审核成功', 1500)
					ctrl.query()
				})
			})
		}
	}
</script>
<div ng-controller="ScoreCertCtrl as subCtrl" ng-init="ctrl.subCtrl=subCtrl;ctrl.query()">
	<div class="">
		<button type="button" class="btn btn-cys btn-sm" ng-click="subCtrl.batch()">
			<span class="glyphicon glyphicon-plus"></span>
			批量审核
		</button>
		<button type="button" class="btn btn-cys btn-sm" ng-click="export(ctrl,'root/score/exportCertReApply')">
			<span class="glyphicon glyphicon-export"></span>
			导出
		</button>
		<div ng-init="ctrl=subCtrl" class="pull-right" ng-include="':root/components/page.html'"></div>
	</div>
	<!-- operation area END -->
	<!-- data grid area -->
	<div style="padding-top: 10px;">
		<table class="table table-bordered table-hover table-striped" ng-init="ctrl=subCtrl">
			<tr>
				<th>
					<input ng-change="ctrl.checkAll(ctrl.$checkAll)" ng-model="ctrl.$checkAll" type="checkbox" />
				</th>
				<th>期数</th>
				<th>姓名</th>
				<th>性别</th>
				<th>学号</th>
				<th>院系</th>
				<!-- <th>专业</th> -->
				<th>所属班级</th>
				<!-- <th>团支书</th> -->
				<th>联系方式</th>
				<th>申请原因</th>
				<th>审核状态</th>
				<th>操作</th>
			</tr>
			<tr ng-repeat="item in ctrl.entities.content">
				<td><input ng-model="item.$checked" type="checkbox" /></td>
				<td>{{item.stuInfo.term.qs}}</td>
				<td>{{item.stuInfo.student.name}}</td>
				<td>{{item.stuInfo.student.sexString}}</td>
				<td>{{item.stuInfo.student.xh}}</td>
				<td>{{item.stuInfo.student.department.name}}</td>
				<!-- <td>{{item.stuInfo.student.major.name}}</td> -->
				<td>{{item.stuInfo.classInfo.bjName}}</td>
				<!-- 	<td>{{item.stuInfo.sfwtzs|toBool}}</td> -->
				<td>{{item.lxfs}}</td>
				<td>{{item.sqyy}}</td>
				<td>{{item.status|auditString}}</td>
				<td><a href="javascript:;" class="remove-underline" ng-click="ctrl.audit(item)">审核</a></td>
			</tr>
		</table>
		<p>
			共有记录：
			<span>{{ctrl.entities.totalElements}}</span>
			条
		</p>
	</div>
	<div class="hidden" ng-non-bindable template>
		<div batch>
			<form class="form-horizontal  text-center">
				<div class="form-group">
					<h4>
						<label>{{desc}}</label>
					</h4>
				</div>
				<div class="form-group">
					<label class="  control-label">审核结果</label>
					<input switch-handle-width="80px" bs-switch type="checkbox" ng-model="result.pass" switch-size="small" switch-on-text="通过"
						switch-off-text="驳回" name="result.pass" />
				</div>
			</form>
		</div>
		<div add>
			<form class="form-horizontal" single-student>
				<div class="form-group" ng-show="search.enable">
					<label class="col-md-2 control-label">学生</label>
					<div class="col-md-10 open">
						<input type="text" ng-change="ctrl.searchStudent(search.name,search)" ng-model="search.name" class="form-control"
							placeholder="按姓名/学号模糊搜索">
						<ul class="dropdown-menu" ng-show="search.students.content.length>0">
							<li ng-repeat="t in search.students.content">
								<a href="javascript:;" ng-click="search.stuInfo=t;result.stuInfo.id=t.id;search.students=null;">({{t.student.xh}}){{t.student.name}}</a>
							</li>
						</ul>
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">姓名</label>
					<div class="col-md-4">
						<input type="text" ng-model="search.stuInfo.student.name" class="form-control" disabled="disabled">

					</div>
					<label class="col-md-2 control-label">性别</label>
					<div class="col-md-4">
						<input type="text" class="form-control" ng-model="search.stuInfo.student.sexString" disabled="disabled">
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">学生类别</label>
					<div class="col-md-4">
						<input type="text" class="form-control" disabled="disabled" value="本科">
					</div>
					<label class="col-md-2 control-label">年级</label>
					<div class="col-md-4">
						<input type="text" class="form-control" ng-model="search.stuInfo.student.grade" disabled="disabled" value="2015">
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">院系</label>
					<div class="col-md-4">
						<input type="text" class="form-control" disabled="disabled" ng-model="search.stuInfo.student.department.name">
					</div>
					<label class="col-md-2 control-label">专业</label>
					<div class="col-md-4">
						<input type="text" class="form-control" disabled="disabled" ng-model="search.stuInfo.student.major.name">
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">校区</label>
					<div class="col-md-4">
						<input class="form-control" disabled="disabled" ng-model="search.stuInfo.xq">
					</div>
					<label class="col-md-2 control-label">联系电话</label>
					<div class="col-md-4">
						<input type="text" disabled="disabled" ng-model="search.stuInfo.lxfs" class="form-control">
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">班级</label>
					<div class="col-md-4">
						<input class="form-control" disabled="disabled" ng-model="search.stuInfo.classInfo.bjName">
					</div>
					<label class="col-md-2 control-label">团支书</label>
					<div class="col-md-4">
						<span class="form-control" disabled="disabled" ng-bind="search.stuInfo.sfwtzs|toBool"></span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">备注</label>
					<div class="col-md-10">
						<input type="text" disabled="disabled" class="form-control" ng-model="search.stuInfo.bz">
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">申请原因</label>
					<div class="col-md-10">
						<textarea rows="3" disabled="disabled" ng-model="result.sqyy" style="resize: none;" name="reason" class="form-control"
							placeholder="申请原因"> </textarea>
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">证明材料</label>
					<div class="col-md-10">
						<a ng-href="{{ctrl.toImageUrl(result.fjId)}}" target="_blank">
							<img class="img-responsive" ng-src="{{ctrl.toImageUrl(result.fjId)}}">
						</a>
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">审核结果</label>
					<div class="col-md-10">
						<input switch-handle-width="80px" bs-switch type="checkbox" ng-model="result.pass" switch-size="small" switch-on-text="通过"
							switch-off-text="驳回" name="result.pass" />
					</div>
				</div>

			</form>
		</div>
	</div>
</div>